function downloadPdf(url, filename) {
	const xhr = new XMLHttpRequest();
	xhr.open("get", url, true);
	xhr.responseType = "blob";
	xhr.onload = () => {
		if (xhr.status === 200) {
			const blob = new Blob([xhr.response], { type: "application/pdf" });
			const url = URL.createObjectURL(blob);
			const a = document.createElement("a");
			a.href = url;
			a.download = filename;
			a.click();
			URL.revokeObjectURL(url);
		}
	};
	xhr.send();
}

// 使用示例
downloadPdf("https://example.com/document.pdf", "document.pdf");
